<?php echo $header; ?><?php echo $column_left; ?>
<div class="page">
      <div class="inner">
          <div class="search_results">
              <table width="100%" border="0" cellpadding="0" cellspacing="0">
                  <tr>
                      <th><?php echo $heading_title; ?></th>
                    </tr>
                    <tr>
                      <td class="title"><?php echo $text_critea; ?></td>
                    </tr>
                    </table>
                    <table width="100%" border="0" cellpadding="0" cellspacing="0" id="content">
                    <tr>
                      <td>search:
                        <?php if ($filter_name) { ?>
                        <input type="text" name="filter_name1" value="<?php echo $filter_name; ?>" />
                        <?php } else { ?>
                        <input type="text" name="filter_name1" value="<?php echo $filter_name; ?>" onclick="this.value = ''" onkeydown="this.style.color = '000000'"/>
                        <?php } ?>
                        <select name="filter_category_id">
                          <option value="0"><?php echo $text_category; ?></option>
                          <?php foreach ($categories as $category_1) { ?>
                          <?php if ($category_1['category_id'] == $filter_category_id) { ?>
                          <option value="<?php echo $category_1['category_id']; ?>" selected="selected"><?php echo $category_1['name']; ?></option>
                          <?php } else { ?>
                          <option value="<?php echo $category_1['category_id']; ?>"><?php echo $category_1['name']; ?></option>
                          <?php } ?>
                          <?php foreach ($category_1['children'] as $category_2) { ?>
                          <?php if ($category_2['category_id'] == $filter_category_id) { ?>
                          <option value="<?php echo $category_2['category_id']; ?>" selected="selected">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<?php echo $category_2['name']; ?></option>
                          <?php } else { ?>
                          <option value="<?php echo $category_2['category_id']; ?>">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<?php echo $category_2['name']; ?></option>
                          <?php } ?>
                          <?php foreach ($category_2['children'] as $category_3) { ?>
                          <?php if ($category_3['category_id'] == $filter_category_id) { ?>
                          <option value="<?php echo $category_3['category_id']; ?>" selected="selected">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<?php echo $category_3['name']; ?></option>
                          <?php } else { ?>
                          <option value="<?php echo $category_3['category_id']; ?>">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<?php echo $category_3['name']; ?></option>
                          <?php } ?>
                          <?php } ?>
                          <?php } ?>
                          <?php } ?>
                        </select>
                        </td>
                        <tr><td>
                         <?php if ($filter_sub_category) { ?>
                          <input type="checkbox" name="filter_sub_category" value="1" id="sub_category" checked="checked" />
                          <?php } else { ?>
                          <input type="checkbox" name="filter_sub_category" value="1" id="sub_category" />
                          <?php } ?>
                          <?php echo $text_sub_category; ?>
                           <?php if ($filter_description) { ?>
                           <input type="checkbox" name="filter_description" value="1" id="description" checked="checked" />
                          <?php } else { ?>
                          <input type="checkbox" name="filter_description" value="1" id="description" />
                          <?php } ?>
                          <?php echo $entry_description; ?>
                        </td></tr>
                    </tr>
                    <tr>
                      <td>
                        <input type="button" class="search_btn" id="button-search1" /></td>
                    </tr>
                    </table>
            </div>
      		<div class="_panel">
	            <h1><span><?php echo $text_search; ?></span></h1>
	              <?php if ($products) { ?>
	              <?php foreach ($products as $product) { ?>
	                <div>
	                	<a href="<?php echo $product['href']; ?>" title="<?php echo $product['old_name']?>">
	                    <?php if ($product['thumb']) { ?>
	                    <img src="<?php echo $product['thumb']; ?>" />
	                    <?php }?>
	                    <h3 style="height:40px;overflow:hidden"><?php echo $product['name']; ?></h3>
	                    <b><?php if (!$product['special']) { ?>
	                      <span class="price-new"><?php echo $product['price']; ?></span>
	                      <?php } else { ?>
	                      <span class="price-old"><?php echo $product['price']; ?></span> <span class="price-new"><?php echo round($product['special'], 2); ?></span>
	                      <?php } ?></b>
	                    <?php if($product['discount_per']){?>
	                      <span>(<?php echo $product['discount_per'];?>%off)</span>
	                      <div><?php echo $product['discount_per'];?>%<br />off</div>
	                    <?php }?>
	                </a>
	                </div>
	              <?php }?>
	              <?php } else { ?>
	                <div class="content" style="width:400px;"><?php echo $text_empty; ?></div>
	              <?php }?>
         	</div>
          	<div class="pagination"><?php echo $pagination; ?></div>
	      </div>  
	    </div>


<script type="text/javascript"><!--
$('#content input[name=\'filter_name1\']').keydown(function(e) {
	if (e.keyCode == 13) {
		$('#button-search1').trigger('click');
	}
});

$('#button-search').bind('click', function() {
	url = 'index.php?route=product/search';
	
	var filter_name = $('#content input[name=\'filter_name\']').attr('value');
	
	if (filter_name) {
		url += '&filter_name=' + encodeURIComponent(filter_name);
	}

	var filter_category_id = $('#content select[name=\'filter_category_id\']').attr('value');
	
	if (filter_category_id > 0) {
		url += '&filter_category_id=' + encodeURIComponent(filter_category_id);
	}
	
	var filter_sub_category = $('#content input[name=\'filter_sub_category\']:checked').attr('value');
	
	if (filter_sub_category) {
		url += '&filter_sub_category=true';
	}
		
	var filter_description = $('#content input[name=\'filter_description\']:checked').attr('value');
	
	if (filter_description) {
		url += '&filter_description=true';
	}
	location = url;
});

$('#button-search1').bind('click', function() {
	url = 'index.php?route=product/search';
	
	var filter_name = $('#content input[name=\'filter_name1\']').attr('value');
	
	if (filter_name) {
		url += '&filter_name=' + encodeURIComponent(filter_name);
	}

	var filter_category_id = $('#content select[name=\'filter_category_id\']').attr('value');
	
	if (filter_category_id > 0) {
		url += '&filter_category_id=' + encodeURIComponent(filter_category_id);
	}
	
	var filter_sub_category = $('#content input[name=\'filter_sub_category\']:checked').attr('value');
	
	if (filter_sub_category) {
		url += '&filter_sub_category=true';
	}
		
	var filter_description = $('#content input[name=\'filter_description\']:checked').attr('value');
	
	if (filter_description) {
		url += '&filter_description=true';
	}
	location = url;
});

function display(view) {
	if (view == 'list') {
		$('.product-grid').attr('class', 'product-list');
		
		$('.product-list > div').each(function(index, element) {
			html  = '<div class="right">';
			html += '  <div class="cart">' + $(element).find('.cart').html() + '</div>';
			html += '  <div class="wishlist">' + $(element).find('.wishlist').html() + '</div>';
			html += '  <div class="compare">' + $(element).find('.compare').html() + '</div>';
			html += '</div>';			
			
			html += '<div class="left">';
			
			var image = $(element).find('.image').html();
			
			if (image != null) { 
				html += '<div class="image">' + image + '</div>';
			}
			
			var price = $(element).find('.price').html();
			
			if (price != null) {
				html += '<div class="price">' + price  + '</div>';
			}
						
			html += '  <div class="name">' + $(element).find('.name').html() + '</div>';
			html += '  <div class="description">' + $(element).find('.description').html() + '</div>';
			
			var rating = $(element).find('.rating').html();
			
			if (rating != null) {
				html += '<div class="rating">' + rating + '</div>';
			}
				
			html += '</div>';

						
			$(element).html(html);
		});		
		
		$('.display').html('<b><?php echo $text_display; ?></b> <?php echo $text_list; ?> <b>/</b> <a onclick="display(\'grid\');"><?php echo $text_grid; ?></a>');
		
		$.cookie('display', 'list'); 
	} else {
		$('.product-list').attr('class', 'product-grid');
		
		$('.product-grid > div').each(function(index, element) {
			html = '';
			
			var image = $(element).find('.image').html();
			
			if (image != null) {
				html += '<div class="image">' + image + '</div>';
			}
			
			html += '<div class="name">' + $(element).find('.name').html() + '</div>';
			html += '<div class="description">' + $(element).find('.description').html() + '</div>';
			
			var price = $(element).find('.price').html();
			
			if (price != null) {
				html += '<div class="price">' + price  + '</div>';
			}	
					
			var rating = $(element).find('.rating').html();
			
			if (rating != null) {
				html += '<div class="rating">' + rating + '</div>';
			}
						
			html += '<div class="cart">' + $(element).find('.cart').html() + '</div>';
			html += '<div class="wishlist">' + $(element).find('.wishlist').html() + '</div>';
			html += '<div class="compare">' + $(element).find('.compare').html() + '</div>';
			
			$(element).html(html);
		});	
					
		$('.display').html('<b><?php echo $text_display; ?></b> <a onclick="display(\'list\');"><?php echo $text_list; ?></a> <b>/</b> <?php echo $text_grid; ?>');
		
		$.cookie('display', 'grid');
	}
}

//view = $.cookie('display');

// if (view) {
// 	display(view);
// } else {
// 	display('list');
// }
//--></script> 
<?php echo $footer; ?>